<script type='text/javascript'>
var myUrl = location.href.match(/^.*\//);
//Set your folder here
var url= location.href.match(/^.*\//);

//SMILIES
function doSmiley() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/grin.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
		formatText(document.getElementById('reply'),':)','');
    }
}

function doWink() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/wink.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),';-)','');
    }
}

function doTongue() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/tongue.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
		formatText(document.getElementById('reply'),':-p','');
    }
}

function doSad() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/sad.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),':-(','');
    }
}

function doLol() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/lol.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),':-D','');
    }
}
function doUp() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/up.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),':up:','');
    }
}
function doGiggle() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/giggle.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),':giggle:','');
    }
}
function doDown() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/down.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),':down:','');
    }
}
function doUp2() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/up2.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	    formatText(document.getElementById('reply'),':up2:','');
    }
}
function doHi() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/hi.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
		 formatText(document.getElementById('reply'),':hi:','');
    }
}
function doNerdy() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/nerdy.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
		formatText(document.getElementById('reply'),'8-)','');
    }
}
function doCool() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/cool.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),':cool:','');
    }
}
function doConfused() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/confused.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),':confused:','');
    }
}
function doNono() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/nono.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),':nono:','');
    }
}
function doShy() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/shy.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),':shy:','');
    }
}
function doWinking() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/winking.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),';-D','');
    }
}
function doSealed() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/sealed.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),':sealed:','');
    }
}
function doLove() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/heart.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),':love:','');
    }
}
function doEvil() {
    if (editorVisible) {
        ifm.contentWindow.focus();
        myimg = url +'img/smilies/evil.gif';
        if ((myimg != null) && (myimg != "")) {
            myeditor.execCommand('InsertImage', false, myimg);
        }
    }
    else {
	formatText(document.getElementById('reply'),':-@','');
    }
}
//END SMILIES
 function confirmDelete(delUrl) {
  if (confirm("Are you sure you want to delete this post?")) {
    document.location = delUrl;
  }
}
</script>
<?php

function smilies($text, $url_address_to_images_folder) // with '/' at the end
{
$array = array(':-)' => 'smile001.gif', // happy 
':)' =>  'grin.gif', // happy 
':-)' =>  'grin.gif', // happy 
':-D' => 'laugh.gif', // very happy 
':D' =>  'laugh.gif', // very happy
':-O' => 'shame.gif', // surprised / o, no   
':-P' => 'tongue.gif', // tongue sticking out
':P' =>  'tongue.gif', // tongue sticking out 
':-p' =>  'tongue.gif', // tongue sticking out 
';-)' => 'wink.gif', // wink 
';-D' =>  'winking.gif', // wink
':-(' => 'sad.gif', // sad 
':(' =>  'sad.gif', // sad
':-@' => 'evil.gif', // angry 
'8-)' => 'nerdy.gif', // nerd 
':confused:' => 'confused.gif', // confused 
':-$' => 'shysmile.gif', // embarrassed 
':love:'=> 'heart.gif', // heart 
':hi:' => 'hi.gif', // hi
':lol:' => 'lol.gif', // lol
':giggle:'=> 'giggle.gif', // giggle
':eek:' => 'eek.gif', // eek
':nodding:' => 'nodding.gif', // nodding
':sealed:' => 'sealed.gif', // sealed
':shame:' => 'shame.gif', // shame
':shy:' => 'shy.gif', // shy
':smile:' => 'smile.gif', // smile
':speachless:' => 'speachless.gif', // speachless
':up2:' => 'up2.gif', // up
':up:' => 'up.gif', // up
':nono:' => 'nono.gif', // up
':hi:' => 'hi.gif'); // money


foreach($array as $s => $xc)
{
$text = str_replace($s, "<img align='absmiddle' border=0 src='".$url_address_to_images_folder.$xc."'>", $text);
}
return $text;		
}
 
?>